define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'dahui/nianyue/index',
                    add_url: 'dahui/nianyue/add',
                    edit_url: 'dahui/nianyue/edit',
                    del_url: 'dahui/nianyue/del',
                    multi_url: 'dahui/nianyue/multi',
                    table: 'dahui_nianyue',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'), sortable: true},
                        {field: 'businessnumber', title: __('Businessnumber'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: Table.api.formatter.search, sortable: true},
                        {field: 'paymentdate', title: __('Paymentdate'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: Table.api.formatter.search, sortable: true},
                        {field: 'payingcompany', title: __('Payingcompany'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: Table.api.formatter.search, sortable: true},
                        {field: 'paymentbase', title: __('Paymentbase'), sortable: true},
                        {field: 'paymentamount', title: __('Paymentamount'), operate:'BETWEEN', sortable: true},
                        {field: 'earlytransfer', title: __('Earlytransfer'), searchList: {"":__(''),"是":__('是') }, formatter: Table.api.formatter.normal, sortable: true},
                        {field: 'newjoin_status', title: __('Newjoin_status'), searchList: {"办理失败":__('办理失败'),"已办理":__('已办理'),"未办理":__('未办理')}, formatter: Table.api.formatter.status, sortable: true},
                        {field: 'zc_status', title: __('Zc_status'), searchList: {"办理失败":__('办理失败'),"已办理":__('已办理'),"未办理":__('未办理')}, formatter: Table.api.formatter.status, sortable: true},
                        {field: 'refundornot', title: __('Refundornot'), searchList: {"":__(''),"已退款":__('已退款'),"待退款":__('待退款'),"需退款":__('需退款')}, formatter: Table.api.formatter.normal, sortable: true},
                        {field: 'taobaoname', title: __('Taobaoname'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: Table.api.formatter.search, sortable: true},
                        //{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime, sortable: true},
                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime, sortable: true},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});